<template>
  <div>
    <div id="swiper-container-banner">
      <div class="swiper-wrapper">
        <div class="swiper-slide">
          <img src="../img/banner1.jpg" width="100%" height="600px" />
        </div>
        <div class="swiper-slide">
          <img src="../img/banner2.jpg" width="100%" height="600px" />
        </div>
        <div class="swiper-slide">
          <img src="../img/banner3.jpg" width="100%" height="600px" />
        </div>
      </div>
      <!-- 如果需要分页器 -->
      <div class="swiper-pagination-banner"></div>
    </div>
  </div>
</template>

<script>
import Swiper from "swiper";
export default {
  methods: {
    banner() {
      var mySwiper = new Swiper("#swiper-container-banner", {
        loop: true, // 循环模式选项
        autoplay: {
          delay: 2000,
          disableOnInteraction: false,
        },
        effect: "fade",

        pagination: {
          el: ".swiper-pagination-banner",
          clickable: true,
          bulletClass: "my-bullet", //需设置.my-bullet样式
          bulletActiveClass: "my-bullet-active",
        },
      });
    },
  },
  mounted() {
    this.banner();
  },
};
</script>

<style lang="scss" scoped>
#swiper-container-banner {
  position: relative;
  width: var(--width);
  overflow: hidden;
}
.swiper-pagination-banner {
  display: flex;
  width: 70px;
  position: absolute;
  bottom: 20px;
  left: 50%;
  z-index: 1;
  transform: translateX(-50%);
  justify-content: space-between;
}
</style>
<style type="text/css">
.my-bullet {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  z-index: 1;
  background-color: #fff;
}
.my-bullet-active {
  background: #ff6600;
  opacity: 1;
}
</style>